﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="channel_list.aspx.cs" Inherits="EZCRS.HCMS.Web.manage.ta.channel_list" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <link type="text/css" href="../../style/main.css" rel="Stylesheet" />

    <script src="../../common/jquery-1.2.6.min.js"></script>

    <script src="../../common/jquery-impromptu.1.5.js"></script>

    <script src="../../common/flexigrid/flexigrid.js"></script>
    
    <script src="../../common/winbox.js"></script>
    
    <link rel="stylesheet" href="../../common/flexigrid/flexigrid.css" type="text/css"
        media="screen" />
    <link rel="stylesheet" href="../../style/dfbDialog.css" type="text/css" media="screen" />
</head>
<body>

    <script type="text/javascript" charset="utf-8">
	
		$(document).ready(function(){
		
		    $('#grid').flexigrid({
		        width: $(document).width() - 10,
		        height: 400,
		        //striped:false,
		        
		        url:'?action=get',
		        
		        dataType: 'json',  
		        
		        colModel: [
		            {display: '编号', name : 'iata', width : 100, sortable : false, align: 'left'},
                    {display: '名称', name : 'name', width : 300, sortable : false, align: 'left'},
                    {display: 'Code', name : 'linkman', width : 100, sortable : false, align: 'left'},
                    {display: '代理商列表', name : 'ta', width : 200, sortable : false, align: 'left'}
                ],
 
                buttons : [
                    { name: '<%= Resources.Site.LabNew %>', bclass:"add", onpress: doCommand},   
                    { name: '<%= Resources.Site.LabDelete %>', bclass:"delete", onpress: doCommand},  
                    { name: '<%= Resources.Site.LabSentRateNotify %>', bclass:"send", onpress: doCommand},   
                    { separator: true}   
                ],  
                
                showTableToggleBtn: true,
                rp: 15,
                usepager: true,
                useRp: true,
                onSuccess: bindEvents
                
		    });
		    
		});
		
		
	    function bindEvents()
        {
            $('#grid tbody tr td').each(function() {
            
                $(this).dblclick(function(e) {
                
                    var row = $(this).parents('tr');
                    
                    var id = row.children('td').eq(0).children('div').get(0).innerHTML;
                    
                    ShowBox("channel_new.aspx?id=" + id, 400);
                    
                });
                
            });
            
        }
		
		function doCommand(com, grid){
		
		    if(com == '<%= Resources.Site.LabNew %>'){
		    
		        ShowBox('channel_new.aspx', 400);
		        
		        //$(document).click();
		        
		        return;
		    }
		
            if($('.trSelected', grid)[0] == null) {
                
                alert('<%= Resources.Site.NoChannelSelected %>');
                return;
            }

            if (com == '<%= Resources.Site.LabSentRateNotify %>'){
                
                if(confirm("<%= Resources.Site.ScriptConfirm %>")){
                
                    var channels = "";
                    
                    $('.trSelected', grid).each(
                    
                        function(){
                            
                            var id = $(this).children('td').eq(0).children('div').get(0).innerHTML;
                            
                            channels += id + ',';
                            
                        }
                    
                    );
                    
                    window.location = "..\\air\\notify_list.aspx?chl=" + channels;
                    
                }
                
                
            }
            else if(com ==  '<%= Resources.Site.LabDelete %>'){
            
                //delete  
                $('.trSelected', grid).each(
                    
                     function(){
                     
                        var id = $(this).children('td').eq(0).children('div').get(0).innerHTML;
                        var name = $(this).children('td').eq(1).children('div').get(0).innerHTML;
                        
                        if(confirm("<%= Resources.Site.ScriptConfirm %>" + "-" + name)){
                            
                            var data = { id: id };
                            
                            $.post("?action=del", data,
                            
                                function(data, state){
                                
                                    if(data.state > 0){
                                        
                                        //error
                                        alert("该渠道包含TA，不能删除！");
                                    }
                                    else{
                                        doRefresh();
                                    }
                                    
                                    
                            }, "json");
                        }
                        
                     }
                    
                );
                

                
            }
            
        }
        
                
        function doRefresh(){
            $('#grid').flexOptions().flexReload();
        }
        

        
    </script>

    <form id="form1" runat="server">
    <div>
    </div>
    </form>
    <table id="grid">
    </table>
    <div id="loadinfo" align="center">
    </div>
</body>
</html>
